function header = univhead(s,p,h)
%UNIVHEAD   makes an universal file header for UNIWRITE
%           header = univhead(s,p,h)
%           header   Header for UNIWRITE
%           s        selection of parameter to enter, see below
%           p        parameter to enter
%           h        old header (new parameter is added to h)
%           NOTE!    Start by making a default header!
%                    Then add the desired parameters
%
%           s        'default'  for default header setup
%                    'rec1'     for UF record 1 max 80 ASCII
%                    'rec2'     for UF record 2 max 80 ASCII
%                    'rec3'     for UF record 3 max 80 ASCII
%                    'rec4'     for UF record 4 max 80 ASCII
%                    'rec5'     for UF record 5 max 80 ASCII
%                    'functype' see manual
%                    'funcid'   see manual
%                    'seqno'    see manual
%                    'lcid'     see manual
%                    'respnam'  see manual
%                    'respnode' see manual
%                    'respdir'  see manual
%                    'refnam'   see manual
%                    'refnode'  see manual
%                    'refdir'   see manual
%                    'xmin'     see manual
%                    'xdelta'   see manual
%                    'xtype'    see manual
%                    'xlabel'   see manual
%                    'xunit'    see manual
%                    'yntype'   see manual
%                    'ynlabel'  see manual
%                    'ynunit'   see manual
%                    'ydtype'   see manual
%                    'ydlabel'  see manual
%                    'ydunit'   see manual
%                    'ztype'    see manual
%                    'zlabel'   see manual
%                    'zunit'    see manual
%

%   Copyright 2001, Saven EduTech AB. 
%   Revision: 1.1  Date: 2001-06-05 


if isequal(s,'default')
   rec1 = ['Record 1',blanks(72)];
   rec2 = ['Record 2',blanks(72)];
   da = datestr(now);
   rec3 = [da(1:7),da(10:20),blanks(62)];
   rec4 = ['Record 4',blanks(72)];
   rec5 = ['Record 5',blanks(72)];
   %
   rec6 = sprintf('%5i%10i%5i%10i%s%10i%4i%s%10i%4i',0,0,1,1,' NONE      ',1,0,' NONE      ',1,0);
   %
   rec7 = [sprintf('%10i%10i%10i',2,1024,1),sprspec(0),sprspec(1.0),sprspec(0),blanks(11)];
   %
   none = ' NONE                ';
   rec8 = sprintf('%10i%5i%5i%5i%s%s',0,0,0,0,none,none);
   header = str2mat(rec1,rec2,rec3,rec4,rec5,rec6,rec7,rec8);
   header = str2mat(header,rec8,rec8,rec8);
end
if isequal(s,'rec1')
   rec = [p,blanks(80-length(p))];
   header = h;
   header(1,:) = rec;
end
if isequal(s,'rec2')
   rec = [p,blanks(80-length(p))];
   header = h;
   header(2,:) = rec;
end
if isequal(s,'rec3')
   rec = [p,blanks(80-length(p))];
   header = h;
   header(3,:) = rec;
end
if isequal(s,'rec4')
   rec = [p,blanks(80-length(p))];
   header = h;
   header(4,:) = rec;
end
if isequal(s,'rec5')
   rec = [p,blanks(80-length(p))];
   header = h;
   header(5,:) = rec;
end
%
% record 6
% DOF Identification
%
if isequal(s,'functype')
   rec = sprintf('%5i',p);
   header = h;
   header(6,1:5) = rec;
end
if isequal(s,'funcid')
   rec = sprintf('%10i',p);
   header = h;
   header(6,6:15) = rec;
end
if isequal(s,'seqno')
   rec = sprintf('%5i',p);
   header = h;
   header(6,16:20) = rec;
end
if isequal(s,'lcid')
   rec = sprintf('%10i',p);
   header = h;
   header(6,21:30) = rec;
end
if isequal(s,'respnam')
   rec = sprintf('%10s',p);
   header = h;
   header(6,32:41) = rec;
end
if isequal(s,'respnode')
   rec = sprintf('%10i',p);
   header = h;
   header(6,42:51) = rec;
end
if isequal(s,'respdir')
   rec = sprintf('%4i',p);
   header = h;
   header(6,52:55) = rec;
end
if isequal(s,'refnam')
   rec = sprintf('%10s',p);
   header = h;
   header(6,57:66) = rec;
end
if isequal(s,'refnode')
   rec = sprintf('%10i',p);
   header = h;
   header(6,67:76) = rec;
end
if isequal(s,'refdir')
   rec = sprintf('%4i',p);
   header = h;
   header(6,77:80) = rec;
end
%
% record 7
% data form
%
if isequal(s,'xmin')
   rec = sprspec(p);
   header = h;
   header(7,31:43) = rec;
end
if isequal(s,'xdelta')
   rec = sprspec(p);
   header = h;
   header(7,44:56) = rec;
end
%
% record 8
% X data characteristics
%
if isequal(s,'xtype')
   rec = sprintf('%10i',p);
   header = h;
   header(8,1:10) = rec;
end
if isequal(s,'xlabel')
   rec = sprintf('%s',p);
   rec = [rec,blanks(20-length(rec))];
   header = h;
   header(8,27:46) = rec;
end
if isequal(s,'xunit')
   rec = sprintf('%s',p);
   rec = [rec,blanks(20-length(rec))];
   header = h;
   header(8,48:67) = rec;
end
%
% record 9
% Ynum data characteristics
%
if isequal(s,'yntype')
   rec = sprintf('%10i',p);
   header = h;
   header(9,1:10) = rec;
end
if isequal(s,'ynlabel')
   rec = sprintf('%s',p);
   rec = [rec,blanks(20-length(rec))];
   header = h;
   header(9,27:46) = rec;
end
if isequal(s,'ynunit')
   rec = sprintf('%s',p);
   rec = [rec,blanks(20-length(rec))];
   header = h;
   header(9,48:67) = rec;
end
%
% record 10
% Yden data characteristics
%
if isequal(s,'ydtype')
   rec = sprintf('%10i',p);
   header = h;
   header(10,1:10) = rec;
end
if isequal(s,'ydlabel')
   rec = sprintf('%s',p);
   rec = [rec,blanks(20-length(rec))];
   header = h;
   header(10,27:46) = rec;
end
if isequal(s,'ydunit')
   rec = sprintf('%s',p);
   rec = [rec,blanks(20-length(rec))];
   header = h;
   header(10,48:67) = rec;
end
%
% record 11
% Z data characteristics
%
if isequal(s,'ztype')
   rec = sprintf('%10i',p);
   header = h;
   header(11,1:10) = rec;
end
if isequal(s,'zlabel')
   rec = sprintf('%s',p);
   rec = [rec,blanks(20-length(rec))];
   header = h;
   header(11,27:46) = rec;
end
if isequal(s,'zunit')
   rec = sprintf('%s',p);
   rec = [rec,blanks(20-length(rec))];
   header = h;
   header(11,48:67) = rec;
end











